package com.kungfuhacking.wristbandpro.login.activity;

import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.TextView;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.base.view.BaseActivity;
import com.kungfuhacking.wristbandpro.custom.InputView;
import com.kungfuhacking.wristbandpro.custom.TitleBarView;
import com.kungfuhacking.wristbandpro.login.presenter.IResetPasswordPresenter;
import com.kungfuhacking.wristbandpro.login.view.IRestpasswordView;
import com.kungfuhacking.wristbandpro.utils.LogUtil;

/**
 * 重新设置密码
 * Created by Aaron on 17/4/17.
 */

public class ResetPasswordActivity extends BaseActivity implements IRestpasswordView {

    private String token;
    private String TAG = getClass().getSimpleName();
    private TitleBarView tbv;
    private InputView ivpwd;
    private InputView ivpwdrepet;
    private TextView tv_next;
    private IResetPasswordPresenter iResetPasswordPresenter = new IResetPasswordPresenter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_set_new_pwd);
        if (bundle != null)
            token = bundle.getString("token");

        LogUtil.e(TAG, "token : " + token);
        initView();
    }

    private void initView() {

        this.tv_next = (TextView) findViewById(R.id.tv_next);
        this.ivpwdrepet = (InputView) findViewById(R.id.iv_pwd_repet);
        this.ivpwd = (InputView) findViewById(R.id.iv_pwd);
        this.tbv = (TitleBarView) findViewById(R.id.tbv);

        tbv.setOnLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        ivpwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        ivpwdrepet.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

        tv_next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                iResetPasswordPresenter.checkInfo();
            }
        });
    }

    @Override
    public String getNewPassword() {
        return ivpwd.getText();
    }

    @Override
    public String getNewPasswordRepet() {
        return ivpwdrepet.getText();
    }


    @Override
    public String getToken() {
        return token;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        iResetPasswordPresenter.clearRequest();
    }
}
